package com.xuyuan.arithmetic.demo;

import lombok.Data;

@Data
public class BitEntity {

    private GenderConst gender;

    public static void main(String[] args) {
        BitEntity bitEntity = new BitEntity();
        bitEntity.setGender(GenderConst.FEMALE);
        if (bitEntity.getGender().isMale()) System.out.println("性别为男");
        if (bitEntity.getGender().isFemale()) System.out.println("性别为女");
    }

    /**
     * 性别：男/女
     */
    enum GenderConst {
        MALE(1), FEMALE(1 << 1);

        private int value;

        GenderConst(int value) {
            this.value = value;
        }

        public boolean isMale() {
            return (this.value & MALE.value) != 0;
        }

        public boolean isFemale() {
            return (this.value & FEMALE.value) != 0;
        }
    }
}
